#if defined(ARCTIC)
/****************************************************************
 *
 * Header Files
 *
 ***************************************************************/

#include "sal.h"
#include "ctc_cli.h"
#include "ctc_cli_common.h"
#include "ctc_xdata_cli.h"
#include "ctc_api.h"
#include "ctcs_api.h"
#include "ctc_error.h"
#include "ctc_debug.h"
#include "ctc_xdata.h"

extern int32
sys_usw_xdata_get_status(uint8 lchip);

extern int32
sys_usw_xdata_get_info(uint8 lchip);

extern int32
sys_usw_xdata_show_solid_map(uint8 lchip, uint8 type, uint8 sub_type);

CTC_CLI(ctc_cli_usw_get_xdata_status,
        ctc_cli_usw_get_xdata_status_cmd,
        "show xdata status",
        CTC_CLI_SHOW_STR,
        "Xdata",
        "Xdata overall status"
        )
{
    int32  ret = 0;

    ret = sys_usw_xdata_get_status(g_api_lchip);

    if (ret < 0)
    {
        ctc_cli_out("%% ret =%d, %s\n", ret, ctc_get_error_desc(ret));
        return CLI_ERROR;
    }

    return ret;
}


CTC_CLI(ctc_cli_usw_get_xdata_info,
        ctc_cli_usw_get_xdata_info_cmd,
        "show xdata info",
        CTC_CLI_SHOW_STR,
        "Xdata",
        "Xdata overall info"
        )
{
    int32  ret = 0;

    ret = sys_usw_xdata_get_info(g_api_lchip);

    if (ret < 0)
    {
        ctc_cli_out("%% ret =%d, %s\n", ret, ctc_get_error_desc(ret));
        return CLI_ERROR;
    }

    return ret;
}

CTC_CLI(ctc_cli_usw_show_xdata_solid_map,
        ctc_cli_usw_show_xdata_solid_map_cmd,
        "show xdata temp-xdata solid-map (pre-scl | pre-egs-scl | pre-flowhash | pre-flowhash-ext | pre-ipfix | pre-egs-ipfix | post-scl | post-l3if | post-tunnel | post-fwd | post-acl | dsscl | dstunnel | dsmpls | dsmacda | dsipda | dsflow | dsacl | dsscl-egs | dsacl-egs |)",
        CTC_CLI_SHOW_STR,
        "Xdata",
        "Temp xData",
        "solic mapping relationship",
        "CTC_XDATA_LOCAL_TYPE_SCL",
        "CTC_XDATA_LOCAL_TYPE_EGS_SCL",
        "CTC_XDATA_LOCAL_TYPE_FLOW_HASH",
        "CTC_XDATA_LOCAL_TYPE_FLOW_HASH_EXT",
        "CTC_XDATA_LOCAL_TYPE_IPFIX",
        "CTC_XDATA_LOCAL_TYPE_EGS_IPFIX",
        "CTC_XDATA_PROF_TYPE_POST_SCL",
        "CTC_XDATA_PROF_TYPE_POST_L3IF",
        "CTC_XDATA_PROF_TYPE_POST_TUNNEL",
        "CTC_XDATA_PROF_TYPE_POST_FWD",
        "CTC_XDATA_PROF_TYPE_POST_ACL",
        "CTC_XDATA_PROF_TYPE_DSSCL",
        "CTC_XDATA_PROF_TYPE_DSTUNNEL",
        "CTC_XDATA_PROF_TYPE_DSMPLS",
        "CTC_XDATA_PROF_TYPE_DSMACDA",
        "CTC_XDATA_PROF_TYPE_DSIPDA",
        "CTC_XDATA_PROF_TYPE_DSFLOW",
        "CTC_XDATA_PROF_TYPE_DSACL",
        "CTC_XDATA_PROF_TYPE_EGS_DSSCL",
        "CTC_XDATA_PROF_TYPE_EGS_DSACL")
{
    int32 ret = 0;
    uint8 index;
    uint8 type = 0; /* 0:all, 1:local xdata, 2: xdata */
    uint8 sub_type = 0;


    index = CTC_CLI_GET_ARGC_INDEX("pre-scl");
    if (0xFF != index)
    {
        type = 1;
        sub_type=CTC_XDATA_LOCAL_TYPE_SCL;
    }
    index = CTC_CLI_GET_ARGC_INDEX("pre-egs-scl");
    if (0xFF != index)
    {
        type = 1;
        sub_type=CTC_XDATA_LOCAL_TYPE_EGS_SCL;
    }
    index = CTC_CLI_GET_ARGC_INDEX("pre-flowhash");
    if (0xFF != index)
    {
        type = 1;
        sub_type=CTC_XDATA_LOCAL_TYPE_FLOW_HASH;
    }
    index = CTC_CLI_GET_ARGC_INDEX("pre-flowhash-ext");
    if (0xFF != index)
    {
        type = 1;
        sub_type=CTC_XDATA_LOCAL_TYPE_FLOW_HASH_EXT;
    }
    index = CTC_CLI_GET_ARGC_INDEX("pre-ipfix");
    if (0xFF != index)
    {
        type = 1;
        sub_type=CTC_XDATA_LOCAL_TYPE_IPFIX;
    }
    index = CTC_CLI_GET_ARGC_INDEX("pre-egs-ipfix");
    if (0xFF != index)
    {
        type = 1;
        sub_type=CTC_XDATA_LOCAL_TYPE_EGS_IPFIX;
    }

    index = CTC_CLI_GET_ARGC_INDEX("post-scl");
    if (0xFF != index)
    {
        type = 2;
        sub_type = CTC_XDATA_PROF_TYPE_POST_SCL;
    }
    index = CTC_CLI_GET_ARGC_INDEX("post-tunnel");
    if (0xFF != index)
    {
        type = 2;
        sub_type = CTC_XDATA_PROF_TYPE_POST_TUNNEL;
    }
    index = CTC_CLI_GET_ARGC_INDEX("post-l3if");
    if (0xFF != index)
    {
        type = 2;
        sub_type = CTC_XDATA_PROF_TYPE_POST_L3IF;
    }
    index = CTC_CLI_GET_ARGC_INDEX("post-fwd");
    if (0xFF != index)
    {
        type = 2;
        sub_type = CTC_XDATA_PROF_TYPE_POST_FWD;
    }
    index = CTC_CLI_GET_ARGC_INDEX("post-acl");
    if (0xFF != index)
    {
        type = 2;
        sub_type = CTC_XDATA_PROF_TYPE_POST_ACL;
    }
    index = CTC_CLI_GET_ARGC_INDEX("dsscl");
    if (0xFF != index)
    {
        type = 2;
        sub_type =  CTC_XDATA_PROF_TYPE_DSSCL;
    }
    index = CTC_CLI_GET_ARGC_INDEX("dstunnel");
    if (0xFF != index)
    {
        type = 2;
        sub_type = CTC_XDATA_PROF_TYPE_DSTUNNEL;
    }
    index = CTC_CLI_GET_ARGC_INDEX("dsmpls");
    if (0xFF != index)
    {
        type = 2;
        sub_type = CTC_XDATA_PROF_TYPE_DSMPLS;
    }
    index = CTC_CLI_GET_ARGC_INDEX("dsmacda");
    if (0xFF != index)
    {
        type = 2;
        sub_type = CTC_XDATA_PROF_TYPE_DSMACDA;
    }
    index = CTC_CLI_GET_ARGC_INDEX("dsipda");
    if (0xFF != index)
    {
        type = 2;
        sub_type = CTC_XDATA_PROF_TYPE_DSIPDA;
    }
    index = CTC_CLI_GET_ARGC_INDEX("dsflow");
    if (0xFF != index)
    {
        type = 2;
        sub_type = CTC_XDATA_PROF_TYPE_DSFLOW;
    }
    index = CTC_CLI_GET_ARGC_INDEX("dsacl");
    if (0xFF != index)
    {
        type = 2;
        sub_type = CTC_XDATA_PROF_TYPE_DSACL;
    }
    index = CTC_CLI_GET_ARGC_INDEX("dsscl-egs");
    if (0xFF != index)
    {
        type = 2;
        sub_type = CTC_XDATA_PROF_TYPE_EGS_DSSCL;
    }
    index = CTC_CLI_GET_ARGC_INDEX("dsacl-egs");
    if (0xFF != index)
    {
        type = 2;
        sub_type = CTC_XDATA_PROF_TYPE_EGS_DSACL;
    }


    ret = sys_usw_xdata_show_solid_map(g_api_lchip,type,sub_type);

    if (ret < 0)
    {
        ctc_cli_out("%% ret =%d, %s\n", ret, ctc_get_error_desc(ret));
        return CLI_ERROR;
    }

    return ret;
}


int32
ctc_usw_xdata_cli_init(void)
{
    install_element(CTC_SDK_MODE, &ctc_cli_usw_get_xdata_status_cmd);
    install_element(CTC_SDK_MODE, &ctc_cli_usw_get_xdata_info_cmd);
    install_element(CTC_SDK_MODE, &ctc_cli_usw_show_xdata_solid_map_cmd);
    return CLI_SUCCESS;
}

int32
ctc_usw_xdata_cli_deinit(void)
{
    uninstall_element(CTC_SDK_MODE, &ctc_cli_usw_get_xdata_status_cmd);
    uninstall_element(CTC_SDK_MODE, &ctc_cli_usw_get_xdata_info_cmd);
    uninstall_element(CTC_SDK_MODE, &ctc_cli_usw_show_xdata_solid_map_cmd);
    return CLI_SUCCESS;
}

#endif
